package com.zygh.policeasset.mapper;

import com.zygh.policeasset.pojo.AssetsImages;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface AssetsImagesMapper {
    @Select({"select * from assets_images where assets_id = #{assetsId}"})
    @Results({@Result(property = "assetsId", column = "assets_id"), @Result(property = "createTime", column = "create_time")})
    AssetsImages findByAssetsId(Integer num);

    @Select({"select * from assets_images where id = #{id}"})
    @Results({@Result(property = "assetsId", column = "assets_id"),
            @Result(property = "createTime", column = "create_time")})
    AssetsImages findById(@Param("id") Integer num);

    @Insert({"insert into assets_images (assets_Id,connect,create_time) values (#{assetsId},#{connect},#{createTime})"})
    Integer add(@Param("assetsId") Integer num, @Param("connect") String str, @Param("createTime") String str2);

    @Update({"<script>update assets_images <set><if test='assetsId != null '>assets_Id=#{assetsId},</if><if test='connect != null and connect.length &gt; 0'>connect=#{connect},</if><if test='createTime != null and createTime.length &gt; 0'>createTime=#{createTime},</if></set>where id=#{id}</script>"})
    Integer update(AssetsImages assetsImages);

    @Delete({"delete from assets_images where id=#{id}"})
    Integer delete(Integer num);

    @Delete({"delete from assets_images where assets_id=#{assetsId}"})
    Integer deleteByAssetsId(Integer num);

    @Update({"<script>" +
            "update assets_images " +
            "<set>" +
            "<if test='connect != null and connect.length &gt; 0'>connect=#{connect},</if>" +
            "</set>" +
            "where assets_id=#{assetsId}" +
            "</script>"})
    Integer updateByAssetId(@Param("assetsId") Integer assetsId,
                            @Param("connect") String connect);

}